import java.util.ArrayList; 

/*
 * This Class contains the Mathmatical functions used in the Class Scoring Application
 */
public class ClassScoreMath {
	
	// PercentDelta is the percent from the average that is computed
	private int PercentDelta = 10;

/*
 * CalcAvg
 * This Function calculates the Average Grade
 * 
 * ArrayList<Integer> - This arraylist contains the grades used for calculations
 */
	public double CalcAvg(ArrayList<Integer> grades)
	{ 
		double Sum = 0;
		for(int i = 0; i<grades.size();i++) 
		{
			Sum = Sum + grades.get(i);
		}

		return (Sum / grades.size());
	}
	
	/*
	 * CalcDelta
	 * This function calculates the Percent Delta
	 */
	public double CalcDelta(double Avg)
	{
		double Delta =  (((double) PercentDelta)/ 100);
		return Avg * Delta;
	}

	/*
	 * CalcHighScore
	 * This function calculates the High Average Score for the test
	 * It takes the Average Score and adds the Percent Delta
	 */
	public double CalcHighScore(ArrayList<Integer> Grades)
	{
		double AvgScore = CalcAvg(Grades);
	
		return AvgScore + CalcDelta(AvgScore);
	}

	/*
	 * CalcLowScore
	 * This function calculates the Low Average Score for the test
	 * It takes the Average Score and subtracts the Percent Delta
	 */
	public double CalcLowScore(ArrayList<Integer> Grades)
	{
		double AvgScore = CalcAvg(Grades);

		return AvgScore - CalcDelta(AvgScore);
	}
}
